import { BASE_URL } from './config.js';

export function request(options) {  

  wx.showLoading({
    title: '正在加载中...',
    mask: true
  });
    
  let {url, method, data} = options;

  return new Promise((res, rej) => {
    wx.request({
      url: BASE_URL + url,
      method: method || 'get',
      data,
      success: res,
      fail: rej,
      complete: () => {
        wx.hideLoading();
      }
    })
  })
}